package com.erp.erp_servers.CarryPlan.Imp;

import com.erp.erp_dao.CarryPlan.CarryPlanDao;
import com.erp.erp_entitys.CarryPlan.CarryPlan;
import com.erp.erp_entitys.Company.CompanyEntity;
import com.erp.erp_entitys.Customer.CustomerEntity;
import com.erp.erp_entitys.User.UserEntity;
import com.erp.erp_servers.CarryPlan.CarryPlanService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 出运计划主信息表(CarryPlan)表服务实现类
 *
 * @author makejava
 * @since 2020-10-15 23:31:21
 */
@Service("carryPlanService")
public class CarryPlanServiceImpl implements CarryPlanService {
    @Resource
    private CarryPlanDao carryPlanDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CarryPlan queryById(Integer id) {
        return this.carryPlanDao.queryById(id);
    }


    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    public PageInfo<CarryPlan> pageSelect(Integer status,String billmesage,String opname,String curropname
            ,String startcratedate,String endcratedate,String companyname
            ,String startcarrydate,String endcarrydate,int page, int limit) {
        PageHelper.startPage(page,limit);
        List<CarryPlan> findlist = this.carryPlanDao.queryAllByLimit(status,billmesage,opname,curropname
                ,startcratedate,endcratedate,companyname
                ,startcarrydate,endcarrydate);
        PageInfo<CarryPlan> pageInfoUserList =  new PageInfo<CarryPlan>(findlist);
        return pageInfoUserList;
    }

    /**
     * 新增数据
     *
     * @param carryPlan 实例对象
     * @return 实例对象
     */
    @Override
    public CarryPlan insert(CarryPlan carryPlan) {
        this.carryPlanDao.insert(carryPlan);
        return carryPlan;
    }

    /**
     * 修改数据
     *
     * @param carryPlan 实例对象
     * @return 实例对象
     */
    @Override
    public CarryPlan update(CarryPlan carryPlan) {
        this.carryPlanDao.update(carryPlan);
        return this.queryById(carryPlan.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.carryPlanDao.deleteById(id) > 0;
    }

    /**
     * 获取公司
     * @return
     */
    @Override
    public List<CompanyEntity> getCompany() {
        return this.carryPlanDao.getCompany();
    }

    /**
     * 获取客户
     * @return
     */
    @Override
    public List<CustomerEntity> getCustomer() {
        return this.carryPlanDao.getCustomer();
    }

    /**
     * 获取用户
     * @return
     */
    @Override
    public List<UserEntity> getUser() {
        return this.carryPlanDao.getUser();
    }
}